package com.waya.demo.test;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class ProgramHttp {
	public static void main(String[] args) throws Exception {
		String url = "https://www.scjysy.net/communityedu/v2/content/news/156";
//		ReadHTMLByUrl.readFile(url,"UTF-8");
//		ReadHTMLByUrl.JsoupHtml(url);
		String html = ReadHTMLByUrl.repairContent(url);
		System.out.println(html);
	}

	// 通过对应 的URL地址，读取页面里面的内容
	public static String getHtmlReadLine(String httpurl) throws Exception {
		String CurrentLine = "";
		String TotalString = "";
		InputStream urlStream;
		String content = "";
		try {
			URL url = new URL(httpurl);
//			Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("cmproxy.gmcc.net", 8081));

			HttpURLConnection connection = (HttpURLConnection) url.openConnection();
			connection.connect();
			urlStream = connection.getInputStream();
			BufferedReader reader = new BufferedReader(new InputStreamReader(urlStream, "utf-8"));
			while ((CurrentLine = reader.readLine()) != null) {
				TotalString += CurrentLine;
			}
			content = TotalString;
		} catch (Exception e) {
			throw e;
			// e.printStackTrace();
		}
		return content;

	}

}
